//
//  CoachViewController.m
//  SanYiTeaching
//
//  Created by 李文强 on 2019/4/3.
//  Copyright © 2019 李文强. All rights reserved.
//

#import "CoachViewController.h"

@interface CoachViewController ()<TeacherLeftDelegate>

@end

@implementation CoachViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    UIView *lineView = [UIView new];
    lineView.frame = CGRectMake(0, 20, APP_WIDTH, 1);
    lineView.backgroundColor = LINCOLOR;
    [self.view addSubview:lineView];
    // Do any additional setup after loading the view.
}
//290-75
- (TeacherLeftView *)leftMenuView{
    if (!_leftMenuView) {
        TeacherLeftView *view = [[TeacherLeftView alloc]initWithFrame:CGRectMake(0, 20, 215*fw, APP_HEIGHT-20) andButtonView:@[@" 在线辅导",@" 补课审批",@" 补课记录",@" 补课邀请"] andImageArray:@[@"wenTiFuDao_buke.png",@"zaiXianDuDao_buke.png",@"buKeGuanLi_buke.png",@"buKeXinXi_buke.png",@"buKeXinXi_buke.png"]];
        view.delegate = self;
        _leftMenuView = view;
    }
    return _leftMenuView;
}
- (UIView *)baseView{
    if (!_baseView) {
        UIView *view = [[UIView alloc]init];
        view.backgroundColor = [UIColor clearColor];
        _baseView = view;
    }
    return _baseView;
}
#pragma mark - 添加子视图
- (void)initSubView{
    self.view.backgroundColor = MAINBACKCOLOR;
    _allViewArray = [NSMutableArray new];
    for (int i = 0; i<5; i++) {
        if (i == 5) {//问题辅导。暂时不要了
            _wenTiFuDaoView = [[WenTiFuDaoVC alloc]init];
            _wenTiFuDaoView.view.frame = CGRectMake(0, 0, APP_WIDTH, APP_HEIGHT);
            _wenTiFuDaoView.view.backgroundColor = CONTENTBACKCOLOR;
            [_allViewArray addObject:_wenTiFuDaoView];
        }else if (i==0){
            _zaiXianFuDaoView = [[ZaiXianFuDaoVC alloc]init];
            _zaiXianFuDaoView.view.frame = CGRectMake(0, 0, APP_WIDTH, APP_HEIGHT);
            _zaiXianFuDaoView.view.backgroundColor = CONTENTBACKCOLOR;
            [_allViewArray addObject:_zaiXianFuDaoView];
        }else if (i == 1){//补课审批
            _buKeGuanLiView = [[BuKeGuanLiVC alloc]init];
            _buKeGuanLiView.view.frame = CGRectMake(0, 0, APP_WIDTH, APP_HEIGHT);
            _buKeGuanLiView.view.backgroundColor = CONTENTBACKCOLOR;
            [_allViewArray addObject:_buKeGuanLiView];
        } else if (i == 3) {
            _inviteVC = [[SYBuKeInviteViewController alloc] init];
            _inviteVC.view.frame = CGRectMake(0, 0, APP_WIDTH, APP_HEIGHT);
            _inviteVC.view.backgroundColor = CONTENTBACKCOLOR;
            [_allViewArray addObject:_inviteVC];
            
        }
        else{
            _buKeInforVC = [[BuKeInformationVC alloc]init];
            _buKeInforVC.view.backgroundColor = CONTENTBACKCOLOR;
            _buKeInforVC.view.frame = CGRectMake(0, 0, APP_WIDTH, APP_HEIGHT);
            [_allViewArray addObject:_buKeInforVC];
        }
    }
    [self.view addSubview:self.leftMenuView];
    [self.view addSubview:self.baseView];
    [_baseView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.leftMenuView.mas_right);
        make.top.equalTo(@20);
        make.right.equalTo(@0);
        make.bottom.equalTo(@0);
    }];
    [self mineClick:0];
}
- (void)initOption{
    
}
- (void)layout{
    
}
#pragma mark - 左侧按钮点击
- (void)mineClick:(int)index{
    UIViewController *vc = _allViewArray[index];
    if (self.currentVC == _allViewArray[index]) {
        return;
    }else{
        [self addChildViewController:vc];
        vc.view.hidden = NO;
        [self.baseView addSubview:vc.view];
        [vc.view mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(self.baseView.mas_left);
            make.right.equalTo(self.baseView.mas_right);
            make.top.equalTo(@0);
            make.bottom.equalTo(self.baseView.mas_bottom);
        }];
        //替换view
        [vc didMoveToParentViewController:self];
        [self.currentVC willMoveToParentViewController:nil];
        [self.currentVC removeFromParentViewController];
        [self.currentVC.view removeFromSuperview];
        self.currentVC.view.hidden = YES;
    }
    if (vc == _zaiXianFuDaoView) {
        [_zaiXianFuDaoView requestDataIsFinished:@"0"];
    } else if (vc == _buKeGuanLiView) {
        [_buKeGuanLiView requestData];
        _buKeGuanLiView.banji = @"0";
        _buKeGuanLiView.dataTime = @"";
    } else if (vc == _buKeInforVC) {
        _buKeInforVC.banjiid = @"";
        _buKeInforVC.dateTime = @"";
        [_buKeInforVC requestDataListArr];
    } else if (vc == _inviteVC) {//补课邀请
        
    }
    
}
/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
